////////////////////////////////////////////////////////////
*****Uganda Water Aid Project Tables
*****Replication files for tables
*****Date started: 2021-06-15
*****Contact: Raymond Caraher
///////////////////////////////////////////////////////////
/////////////////////////////
* Install packages if not already installed*

* ssc install estout, replace
* ssc install reghdfe, replace
* ssc install tabout, replace

/////////////////////////////
* Clear *
/////////////////////////////

clear
eststo clear

/////////////////////////////
* Options *
/////////////////////////////

set more off

* Note: will need to change file directory for your setup to point to the data folder
global path "C:\Users\raymo\OneDrive - University of Massachusetts\Academic\RA\UNPS\Analysis\replication-data\"

cd "$path"


/////////////////////////////
* Load data
/////////////////////////////

use unps_gsec_aid_rep_data.dta

drop if missing_coords == 1

encode district, gen(district_code)

global treat_vars treat_1km treat_5km treat_10km treat_15km treat_20km treat_25km
global treat_vars_2 treat_5km treat_10km treat_15km treat_20km treat_25km

capture: gen mot_urb = motorvehicle * urban


/////////////////////////////
* PCA
/////////////////////////////

pca abroad_remit metal_roof metal_wall generator non_agri_land
predict double pca1

/////////////////////////////
* Generate tables
/////////////////////////////

/////////////////////////////
* Summary statistics

* Outcomes by region and year

tabout year region using "$path\..\replication-tables\imp_wat_summ.tex", replace ///
c(mean water_improved) sum style(tex) bt h1(nil) h3(nil)

tabout year region using "$path\..\replication-tables\wat_trav_summ.tex", replace ///
c(mean water_travel_time) sum style(tex) bt h1(nil) h3(nil)

tabout year region using "$path\..\replication-tables\wat_wait_summ.tex", replace ///
c(mean water_waiting_time) sum style(tex) bt h1(nil) h3(nil)

* Correlation matrix for income variables

label variable abroad_remit Remittances
label variable metal_roof Roof 
label variable metal_wall Wall 
label variable motorvehicle Motorvehicle 
label variable generator Generator 
label variable non_agri_land Land

eststo clear

estpost corr abroad_remit metal_roof metal_wall generator non_agri_land, matrix  listwise
esttab using "$path\..\Tables\income_corr_mat.tex", replace label ///
unstack not noobs nonote b(3) nostar nonumbers nodepvars booktabs nomtitle ///
rename(abroad_remit Remittances metal_roof Roof, metal_wall Wall, motorvehicle Motorvehicle, generator Generator, non_agri_land Land) ///
coeflabels(abroad_remit Remittances metal_roof Roof metal_wall Wall motorvehicle Motorvehicle generator Generator non_agri_land Land) ///
title("Correlation coefficients for wealth variables" \label{income-corr-mat})

estpost corr abroad_remit metal_roof metal_wall generator non_agri_land, matrix  listwise
esttab using "$path\..\Tables\Word Tables\income_corr_mat.rtf", replace label ///
unstack not noobs nonote b(3) nostar nonumbers nodepvars nomtitle compress ///
rename(abroad_remit Remittances metal_roof Roof, metal_wall Wall, motorvehicle Motorvehicle, generator Generator, non_agri_land Land) ///
coeflabels(abroad_remit Remittances metal_roof Roof metal_wall Wall motorvehicle Motorvehicle generator Generator non_agri_land Land) ///
title("Correlation coefficients for wealth variables")

/////////////////////////////
* Regressions
/////////////////////////////



/////////////////////////////
* Basic models

* Improved water

eststo clear

foreach v of global treat_vars {

eststo: reghdfe water_improved `v', absorb(district_code survey_wave) vce(cluster id)

}

esttab using "$path\..\replication-tables\imp_wat_basic.tex", replace ///
se b(3) se(3) nocon booktabs ///
mtitles(1km 5km 10km 15km 20km 25km) ///
rename(treat_1km Aid, treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Improved water, basic DID" \label{imp-wat-basic})


esttab using "$path\..\replication-tables\imp_wat_basic.rtf", replace ///
se b(3) se(3) nocon compress modelwidth(6) varwidth(11) ///
mtitles(1km 5km 10km 15km 20km 25km) ///
rename(treat_1km Aid, treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Improved water, basic DID")

eststo clear

* Water travel time

foreach v of global treat_vars {

eststo: reghdfe water_travel_time `v', absorb(district_code survey_wave) vce(cluster id)

}

esttab using "$path\..\replication-tables\wat_trav_basic.tex", replace ///
se b(3) se(3) nocon booktabs ///
mtitles(1km 5km 10km 15km 20km 25km) ///
rename(treat_1km Aid, treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Water travel time, basic DID" \label{wat-trav-basic})

esttab using "$path\..\replication-tables\wat_trav_basic.rtf", replace ///
se b(3) se(3) nocon compress modelwidth(6) varwidth(11) ///
mtitles(1km 5km 10km 15km 20km 25km) ///
rename(treat_1km Aid, treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Water travel time, basic DID")

eststo clear

* Water waiting time

foreach v of global treat_vars {

eststo: reghdfe water_waiting_time `v', absorb(district_code survey_wave) vce(cluster id)

}

esttab using "$path\..\replication-tables\wat_wait_basic.tex", replace ///
se b(3) se(3) nocon booktabs ///
mtitles(1km 5km 10km 15km 20km 25km) ///
rename(treat_1km Aid, treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Water waiting time, basic DID" \label{wat-wait-basic})

esttab using "$path\..\replication-tables\wat_wait_basic.rtf", replace ///
se b(3) se(3) nocon compress modelwidth(6) varwidth(11) ///
mtitles(1km 5km 10km 15km 20km 25km) ///
rename(treat_1km Aid, treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Water waiting time, basic DID")

eststo clear

/////////////////////////////
* Full models

* Improved water

foreach v of global treat_vars {

eststo: reghdfe water_improved `v' ///
hh_size hh_head_educ_primary hh_head_female urban ///
abroad_remit metal_roof metal_wall generator non_agri_land, absorb(district_code survey_wave) vce(cluster id)

}

esttab using "$path\..\replication-tables\imp_wat_full.tex", replace ///
se b(3) se(3) nocon booktabs ///
mtitles(1km 5km 10km 15km 20km 25km) ///
rename(treat_1km Aid, treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, abroad_remit Remittances ///
metal_roof Roof, metal_wall Wall, motorvehicle Motorvehicle, generator Generator, non_agri_land Land) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Improved water, full DID" \label{imp-wat-full})

esttab using "$path\..\replication-tables\imp_wat_full.rtf", replace ///
se b(3) se(3) nocon compress modelwidth(6) varwidth(11) ///
mtitles(1km 5km 10km 15km 20km 25km) ///
rename(treat_1km Aid, treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, abroad_remit Remittances ///
metal_roof Roof, metal_wall Wall, motorvehicle Motorvehicle, generator Generator, non_agri_land Land) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Improved water, full DID")

eststo clear


* Water travel time

foreach v of global treat_vars {

eststo: reghdfe water_travel_time `v' ///
hh_size hh_head_educ_primary hh_head_female urban ///
abroad_remit metal_roof metal_wall generator non_agri_land, absorb(district_code survey_wave) vce(cluster id)

}


esttab using "$path\..\replication-tables\wat_trav_full.tex", replace ///
se b(3) se(3) nocon booktabs ///
mtitles(1km 5km 10km 15km 20km 25km) ///
rename(treat_1km Aid, treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, abroad_remit Remittances ///
metal_roof Roof, metal_wall Wall, motorvehicle Motorvehicle, generator Generator, non_agri_land Land) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Water travel time, full DID" \label{wat-trav-full})

esttab using "$path\..\replication-tables\wat_trav_full.rtf", replace ///
se b(3) se(3) nocon compress modelwidth(6) varwidth(11) ///
mtitles(1km 5km 10km 15km 20km 25km) ///
rename(treat_1km Aid, treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, abroad_remit Remittances ///
metal_roof Roof, metal_wall Wall, motorvehicle Motorvehicle, generator Generator, non_agri_land Land) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Water travel time, full DID")

eststo clear

* Water waiting time

foreach v of global treat_vars {

eststo: reghdfe water_waiting_time `v' ///
hh_size hh_head_educ_primary hh_head_female urban ///
abroad_remit metal_roof metal_wall generator non_agri_land, absorb(district_code survey_wave) vce(cluster id)

}


esttab using "$path\..\replication-tables\wat_wait_full.tex", replace ///
se b(3) se(3) nocon booktabs ///
mtitles(1km 5km 10km 15km 20km 25km) ///
rename(treat_1km Aid, treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, abroad_remit Remittances ///
metal_roof Roof, metal_wall Wall, motorvehicle Motorvehicle, generator Generator, non_agri_land Land) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Water waiting time, full DID" \label{wat-wait-full})

esttab using "$path\..\replication-tables\wat_wait_full.rtf", replace ///
se b(3) se(3) nocon compress modelwidth(6) varwidth(11) ///
mtitles(1km 5km 10km 15km 20km 25km) ///
rename(treat_1km Aid, treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, abroad_remit Remittances ///
metal_roof Roof, metal_wall Wall, motorvehicle Motorvehicle, generator Generator, non_agri_land Land) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Water waiting time, full DID")

eststo clear


/////////////////////////////
* PCA Models

* Improved water

foreach v of global treat_vars {

eststo: reghdfe water_improved `v' ///
hh_size hh_head_educ_primary hh_head_female urban ///
pca1, absorb(district_code survey_wave) vce(cluster id)

}

esttab using "$path\..\replication-tables\imp_wat_pca.tex", replace ///
se b(3) se(3) nocon booktabs ///
mtitles(1km 5km 10km 15km 20km 25km) ///
rename(treat_1km Aid, treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, pca1 PCA) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Improved water, PCA DID" \label{imp-wat-pca})

esttab using "$path\..\replication-tables\imp_wat_pca.rtf", replace ///
se b(3) se(3) nocon compress modelwidth(6) varwidth(11) ///
mtitles(1km 5km 10km 15km 20km 25km) ///
rename(treat_1km Aid, treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, pca1 PCA) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Improved water, PCA DID")

eststo clear


* Water travel time

foreach v of global treat_vars {

eststo: reghdfe water_travel_time `v' ///
hh_size hh_head_educ_primary hh_head_female urban ///
pca1, absorb(district_code survey_wave) vce(cluster id)

}


esttab using "$path\..\replication-tables\wat_trav_pca.tex", replace ///
se b(3) se(3) nocon booktabs ///
mtitles(1km 5km 10km 15km 20km 25km) ///
rename(treat_1km Aid, treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, pca1 PCA) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Water travel time, PCA DID" \label{wat-trav-pca})

esttab using "$path\..\replication-tables\wat_trav_pca.rtf", replace ///
se b(3) se(3) nocon compress modelwidth(6) varwidth(11) ///
mtitles(1km 5km 10km 15km 20km 25km) ///
rename(treat_1km Aid, treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, pca1 PCA) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Water travel time, PCA DID")

eststo clear

* Water waiting time

foreach v of global treat_vars {

eststo: reghdfe water_waiting_time `v' ///
hh_size hh_head_educ_primary hh_head_female urban ///
pca1, absorb(district_code survey_wave) vce(cluster id)

}


esttab using "$path\..\replication-tables\wat_wait_pca.tex", replace ///
se b(3) se(3) nocon booktabs ///
mtitles(1km 5km 10km 15km 20km 25km) ///
rename(treat_1km Aid, treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, pca1 PCA) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Water waiting time, PCA DID" \label{wat-wait-pca})

esttab using "$path\..\replication-tables\wat_wait_pca.rtf", replace ///
se b(3) se(3) nocon compress modelwidth(6) varwidth(11) ///
mtitles(1km 5km 10km 15km 20km 25km) ///
rename(treat_1km Aid, treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, pca1 PCA) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Water waiting time, PCA DID")


eststo clear

/////////////////////////////
* IPW Regression

* Improved water

capture: drop ipw ps

foreach v of global treat_vars {

teffects ipw (water_improved) (`v' water_improved_2005 water_improved_diff_09_05 water_improved_diff_10_09, probit), atet aequations
predict ps, ps

gen ipw = 1 if `v' == 1
replace ipw = ps / (1 - ps) if `v' == 0

eststo: reghdfe water_improved `v' ///
hh_size hh_head_educ_primary hh_head_female urban ///
pca1 [pweight=ipw], absorb(district_code survey_wave) vce(cluster id)

drop ipw ps


}

esttab using "$path\..\replication-tables\imp_wat_ipw.tex", replace ///
se b(3) se(3) nocon booktabs ///
mtitles(1km 5km 10km 15km 20km 25km) ///
rename(treat_1km Aid, treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, pca1 PCA) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("Weighted regressions using IPW weights. All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Improved water, IPW DID" \label{imp-wat-ipw})

esttab using "$path\..\replication-tables\imp_wat_ipw.rtf", replace ///
se b(3) se(3) nocon compress modelwidth(6) varwidth(11) ///
mtitles(1km 5km 10km 15km 20km 25km) ///
rename(treat_1km Aid, treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, pca1 PCA) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("Weighted regressions using IPW weights. All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Improved water, IPW DID")

eststo clear

* Water travel time

capture: drop ipw ps

foreach v of global treat_vars_2 {

teffects ipw (water_travel_time) (`v' water_travel_time_2005 water_travel_time_diff_09_05 water_travel_time_diff_10_09, probit), atet aequations
predict ps, ps

gen ipw = 1 if `v' == 1
replace ipw = ps / (1 - ps) if `v' == 0

eststo: reghdfe water_travel_time `v' ///
hh_size hh_head_educ_primary hh_head_female urban ///
pca1 [pweight=ipw], absorb(district_code survey_wave) vce(cluster id)

drop ipw ps


}


esttab using "$path\..\replication-tables\wat_trav_ipw.tex", replace ///
se b(3) se(3) nocon booktabs ///
mtitles(5km 10km 15km 20km 25km) ///
rename(treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, pca1 PCA) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("Weighted regressions using IPW weights. All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Water travel time, IPW DID" \label{wat-trav-ipw})

esttab using "$path\..\replication-tables\wat_trav_ipw.rtf", replace ///
se b(3) se(3) nocon compress modelwidth(6) varwidth(11) ///
mtitles(5km 10km 15km 20km 25km) ///
rename(treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, pca1 PCA) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("Weighted regressions using IPW weights. All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Water travel time, IPW DID")

eststo clear

* Water waiting time

capture: drop ipw ps

foreach v of global treat_vars_2 {

teffects ipw (water_waiting_time) (`v' water_waiting_time_2005 water_waiting_time_diff_09_05 water_waiting_time_diff_10_09, probit), atet aequations
predict ps, ps

gen ipw = 1 if `v' == 1
replace ipw = ps / (1 - ps) if `v' == 0

eststo: reghdfe water_waiting_time `v' ///
hh_size hh_head_educ_primary hh_head_female urban ///
pca1 [pweight=ipw], absorb(district_code survey_wave) vce(cluster id)

drop ipw ps


}

esttab using "$path\..\replication-tables\wat_wait_ipw.tex", replace ///
se b(3) se(3) nocon booktabs ///
mtitles(5km 10km 15km 20km 25km) ///
rename(treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, pca1 PCA) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("Weighted regressions using IPW weights. All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Water waiting time, IPW DID" \label{wat-wait-ipw})

esttab using "$path\..\replication-tables\wat_wait_ipw.rtf", replace ///
se b(3) se(3) nocon compress modelwidth(6) varwidth(11) ///
mtitles(5km 10km 15km 20km 25km) ///
rename(treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, pca1 PCA) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("Weighted regressions using IPW weights. All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Water waiting time, IPW DID")

eststo clear

capture: drop ipw ps

/////////////////////////////
* IPW Regression with full wealth variables

capture: drop ipw ps

foreach v of global treat_vars {

teffects ipw (water_improved) (`v' water_improved_2005 water_improved_diff_09_05 water_improved_diff_10_09, probit), atet aequations
predict ps, ps

gen ipw = 1 if `v' == 1
replace ipw = ps / (1 - ps) if `v' == 0

eststo: reghdfe water_improved `v' ///
hh_size hh_head_educ_primary hh_head_female urban ///
abroad_remit metal_roof metal_wall generator non_agri_land [pweight=ipw], absorb(district_code survey_wave) vce(cluster id)

drop ipw ps


}

esttab using "$path\..\replication-tables\imp_wat_ipw_allwealth.tex", replace ///
se b(3) se(3) nocon booktabs ///
mtitles(1km 5km 10km 15km 20km 25km) ///
rename(treat_1km Aid, treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, pca1 PCA) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("Weighted regressions using IPW weights. All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Improved water, IPW DID" \label{imp-wat-ipw})

esttab using "$path\..\replication-tables\imp_wat_ipw_allwealth.rtf", replace ///
se b(3) se(3) nocon compress modelwidth(6) varwidth(11) ///
mtitles(1km 5km 10km 15km 20km 25km) ///
rename(treat_1km Aid, treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, pca1 PCA) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("Weighted regressions using IPW weights. All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Improved water, IPW DID")

eststo clear

* Water travel time

capture: drop ipw ps

foreach v of global treat_vars_2 {

teffects ipw (water_travel_time) (`v' water_travel_time_2005 water_travel_time_diff_09_05 water_travel_time_diff_10_09, probit), atet aequations
predict ps, ps

gen ipw = 1 if `v' == 1
replace ipw = ps / (1 - ps) if `v' == 0

eststo: reghdfe water_travel_time `v' ///
hh_size hh_head_educ_primary hh_head_female urban ///
abroad_remit metal_roof metal_wall generator non_agri_land [pweight=ipw], absorb(district_code survey_wave) vce(cluster id)

drop ipw ps


}


esttab using "$path\..\replication-tables\wat_trav_ipw.tex_allwealth", replace ///
se b(3) se(3) nocon booktabs ///
mtitles(5km 10km 15km 20km 25km) ///
rename(treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, pca1 PCA) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("Weighted regressions using IPW weights. All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Water travel time, IPW DID" \label{wat-trav-ipw})

esttab using "$path\..\replication-tables\wat_trav_ipw_allwealth.rtf", replace ///
se b(3) se(3) nocon compress modelwidth(6) varwidth(11) ///
mtitles(5km 10km 15km 20km 25km) ///
rename(treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, pca1 PCA) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("Weighted regressions using IPW weights. All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Water travel time, IPW DID")

eststo clear

* Water waiting time

capture: drop ipw ps

foreach v of global treat_vars_2 {

teffects ipw (water_waiting_time) (`v' water_waiting_time_2005 water_waiting_time_diff_09_05 water_waiting_time_diff_10_09, probit), atet aequations
predict ps, ps

gen ipw = 1 if `v' == 1
replace ipw = ps / (1 - ps) if `v' == 0

eststo: reghdfe water_waiting_time `v' ///
hh_size hh_head_educ_primary hh_head_female urban ///
abroad_remit metal_roof metal_wall generator non_agri_land [pweight=ipw], absorb(district_code survey_wave) vce(cluster id)

drop ipw ps


}

esttab using "$path\..\replication-tables\wat_wait_ipw_allwealth.tex", replace ///
se b(3) se(3) nocon booktabs ///
mtitles(5km 10km 15km 20km 25km) ///
rename(treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, pca1 PCA) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("Weighted regressions using IPW weights. All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Water waiting time, IPW DID" \label{wat-wait-ipw})

esttab using "$path\..\replication-tables\wat_wait_ipw_allwealth.rtf", replace ///
se b(3) se(3) nocon compress modelwidth(6) varwidth(11) ///
mtitles(5km 10km 15km 20km 25km) ///
rename(treat_5km Aid, treat_10km Aid, treat_15km Aid, treat_20km Aid, treat_25km Aid, ///
hh_size Size, hh_head_educ_primary Education, hh_head_female Female, urban Urban, pca1 PCA) ///
label star( * 0.10 ** 0.05 *** 0.010) ///
addnotes("Weighted regressions using IPW weights. All models include district and survey year fixed-effects." "Reported standard errors are clustered at the household level.") ///
title("Water waiting time, IPW DID")

eststo clear

capture: drop ipw ps

///////////////////////////////////////////////////////////
